﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using moc.IBLL;
using moc.Models;
using moc.IDAL;

namespace moc.BLL
{
    public class AdminRoleBll :BaseBll, IAdminRoleBll
    {
        
        private readonly IAdminRoleDal _dal;

        public AdminRoleBll(IUnitOfWork unitOfWork,IAdminRoleDal dal) : base(unitOfWork)
        {
            _dal = dal;
        }

        /// <summary>
        /// 添加权限角色
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool AddRole(AdminRole role)
        {
            _dal.Add(role);
            return (_unitOfWork.SaveChanges() > 0);
        }

        /// <summary>
        /// 删除权限角色
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool DeleteRole(List<AdminRole> list)
        {
            _dal.Delete(list);
            return (_unitOfWork.SaveChanges() > 0);
        }
      
        /// <summary>
        /// 修改权限角色
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool EditRole(AdminRole role)
        {
            _dal.Update(role);
            return (_unitOfWork.SaveChanges() > 0);
        }

        /// <summary>
        /// 获取权限角色信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IQueryable<AdminRole> GetRole(int id)
        {
            return _dal.LoadEntities(u => u.Role_id == id);
        }

       
    }
}
